<!DOCTYPE html>
<html lang="en">

<head>
     <?php include 'js.html' ?>
</head>

<body>
    <?php include 'Header.html' ?>
    <div class="main-container" id="main-container">
        <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {}
        </script>
        <div class="main-container-inner">
            <a class="menu-toggler" id="menu-toggler" href="#">
                <span class="menu-text"></span>
            </a>

            <?php include 'menu.html' ?>
            <!-- 中间内容部分 -->
            <div class="main-content">
                <div class="breadcrumbs" id="breadcrumbs">
                    <script type="text/javascript">
                    try {
                        ace.settings.check('breadcrumbs', 'fixed')
                    } catch (e) {}
                    </script>
                    <ul class="breadcrumb">
                        <li>
                            <i class="icon-home home-icon"></i>
                            <a href="#">首页</a>
                        </li>
                        <li class="active">购买管理</li>
                    </ul>
                </div>
                <div class="page-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <ul class="Sam-creat-doc-account clearfix">
                                <li>
                                    <div class="tabbable">
                                        <ul class="nav nav-tabs" id="myTab">
                                            <!-- tab-1 -->
                                          
                                            <!-- tab-2 -->
                                            <li class="active">
                                                <a data-toggle="tab" href="#profile">
                                                    <i class="green icon-briefcase bigger-110"></i> 姓名搜索
                                                </a>
                                            </li>
                                            <!-- tab-3 -->
                                            <li>
                                                <a data-toggle="tab" href="#typesearch">
                                                    <i class="green icon-briefcase bigger-110"></i> 手机号搜索
                                                </a>
                                            </li>

                                            <li>
                                                <a data-toggle="tab" href="#yishensearch">
                                                    <i class="green icon-briefcase bigger-110"></i> 所属医生搜索
                                                </a>
                                            </li>
                                            <li >
                                                <a data-toggle="tab" href="#home">
                                                    <i class="green icon-calendar bigger-110"></i> 日期搜索
                                                </a>
                                            </li>
                                            <!-- tab-4 -->
                                            <li class="pull-right">
                                                    <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#myModal">
                                                            单个添加
                                                    </button>
                                                     <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#myModal2">
                                                    批量导入
                                                    </button>
                                                    <a href="<?php echo base_url('assets/upload').'/'.$this->session->userdata('admin').'_buy.xls' ?>" target='_blank' target='_blank'  class="btn btn-success btn-sm fileBlock">
                                                           导出Excel
                                                    </a> 
                                                  <!--    <a href="#" class="btn btn-success btn-sm fileBlock" onClick ="$('#sample-table-2').tableExport({type:'excel', separator:';', escape:'false'});">导出Excel</a> -->
                                                <!-- 创建医生账号 点击弹出层 -->
                                                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                                    <div class="modal-dialog" role="document">
                                                        <div class="modal-content">
                                                            <div class="modal-body">
                                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                                <h4 class="modal-title" id="myModalLabel">
												        	<p>姓名：<input id="addNameid" type="text" placeholder="添加姓名"></p>
												             </h4>
                                                              <h4 class="modal-title" id="myModalLabel">
                                                            <p>电话：<input id="addMobileid" type="text" placeholder="添加电话"></p>
                                                             </h4>
                                                               <h4 class="modal-title" id="myModalLabel">
                                                            <p>收货地址：<input id="addAddressid" type="text" placeholder="添加收货地址"></p>
                                                             </h4>
                                                               <h4 class="modal-title" id="myModalLabel">
                                                            <p>产品：<input id="addProuctid" type="text" placeholder="添加产品"></p>
                                                             </h4>
                                                               <h4 class="modal-title" id="myModalLabel">
                                                            <p>单价：<input id="addOpriceid" type="text" placeholder="添加单价"></p>
                                                             </h4>
                                                               <h4 class="modal-title" id="myModalLabel">
                                                            <p>数量：<input id="addnumberid" type="text" placeholder="添加数量"></p>
                                                             </h4>
                                                               <h4 class="modal-title" id="myModalLabel">
                                                            <p>总价：<input id="addApriceid" type="text" placeholder="添加总价"></p>
                                                             </h4>
                                                             <h4 class="modal-title" id="myModalLabel">
                                                            <p>购买时间：<input id="addBuyTimeid" type="text" placeholder="添加购买时间">格式：2016-03-01</p>
                                                             </h4>
                                                             <h4 class="modal-title" id="myModalLabel">
                                                            <p>备注：<input id="addBeizhu" type="text" placeholder="添加备注"></p>
                                                             </h4>
                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-success" onclick="subAddDoctor()">确认</button>
                                                                <button type="button" id="btnAddFormOff" class="btn btn-default" onclick="shuaxin()" data-dismiss="modal">关闭</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                                    <div class="modal-dialog" role="document">
                                                        <div class="modal-content">
                                                            <div class="modal-body">
                                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                                <h4 class="modal-title" id="myModalLabel">
                                                                请先 <a href="<?php echo base_url('assets/template/Template.xls') ?>" class="btn btn-success btn-xs"> 下载模板</a>将数据填充至对应位置，保存后进行文件上传
                                                             <p></p>
                                                           <form action="<?php echo site_url("admin/BuyMan/upload") ?>" enctype="multipart/form-data" method="post"
                                                        name="uploadfile">
                                                              选择文件：<input class="fileBlock" type="file" id="id-input-file-2" name="upload_file1" />
                                                             </h4>
                                                            </div>
                                                            <div class="modal-footer">
                                                               <input type="submit" class="btn btn-success btn-sm" value="开始上传" />
                                                                <button type="button" id="btnAddFormOff" class="btn btn-default" onclick="shuaxin()" data-dismiss="modal">关闭</button>
                                                            </div>
                                                             </form> 
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                                        <!-- tab-内容部分 -->
                                        <div class="tab-content">
                                            <!-- 内容1 -->
                                            <div id="home" class="tab-pane">
                                                <label for="id-date-picker-1">
                                                    请选择日期进行查询：
                                                </label>
                                                <!--             <div class="row">
                                                     <div class="col-xs-3 col-sm-4">
                                                        <div class="input-group">
                                                        	<span class="input-group-addon">
																起始日期 <i class="icon-calendar bigger-110"></i>
															</span>
                                                            <input class="form-control date-picker" id="id-date-picker-1" type="text" data-date-format="dd-mm-yyyy" />
                                                        </div>
                                                    </div> 
                                                     <div class="col-xs-3 col-sm-4">
                                                        <div class="input-group">
                                                        	<span class="input-group-addon">
																结束日期 <i class="icon-calendar bigger-110"></i>
															</span>
                                                            <input class="form-control date-picker" id="id-date-picker-1" type="text" data-date-format="dd-mm-yyyy" />
                                                        </div>
                                                    </div> 
                                                    <button class="btn btn-success btn-sm">搜索<i class="icon-search icon-on-right bigger-110"></i></button>
                                                </div> -->
                                                <!-- <br> -->
                                                <div class="row">
                                                    <div class="col-xs-3 col-sm-5">
                                                        <div class="input-group">
                                                            <span class="input-group-addon">
                                                				<i class="icon-calendar bigger-110"></i>
                                                			</span>
                                                            <input class="form-control" id="timeid" type="text" name="date-range-picker" id="id-date-range-picker-1" />
                                                        </div>
                                                    </div>
                                                    <button onclick="searchTime()" class="btn btn-success btn-sm">搜索<i class="icon-search icon-on-right bigger-110"></i></button>
                                                </div>
                                            </div>
                                            <!-- 内容2 -->
                                            <div id="profile" class="tab-pane in active">
                                                <form class="form-search">
                                                    <label for="id-date-picker-1">请输入患者姓名进行查询：</label>
                                                    <div class="row">
                                                        <div class="col-xs-3 col-sm-5">
                                                            <div class="input-group">
                                                                <span class="input-group-addon">
                                                            		<i class="icon-info-sign bigger-110"></i>
                                                            	</span>
                                                                <input id="docotrNameid" class="form-control" type="text" />
                                                            </div>
                                                        </div>
                                                        <button onclick="searchDoctor()" type="button" class="btn btn-success btn-sm">
                                                        	搜索
                                                        	<i class="icon-search icon-on-right bigger-110"></i>
                                                        </button>
                                                    </div>
                                                </form>
                                            </div>

                                             <div id="yishensearch" class="tab-pane">
                                                <form class="form-search">
                                                    <label for="id-date-picker-1">请输入所属医生的姓名进行查询：</label>
                                                    <div class="row">
                                                        <div class="col-xs-3 col-sm-5">
                                                            <div class="input-group">
                                                                <span class="input-group-addon">
                                                                    <i class="icon-info-sign bigger-110"></i>
                                                                </span>
                                                                <input id="DoctorId" class="form-control" type="text" />
                                                            </div>
                                                        </div>
                                                        <button onclick="searchDName()" type="button" class="btn btn-success btn-sm">
                                                            搜索
                                                            <i class="icon-search icon-on-right bigger-110"></i>
                                                        </button>
                                                    </div>
                                                </form>
                                            </div>
                                            <!-- 内容3 -->
                                            <div id="typesearch" class="tab-pane">
                                                <label for="id-date-picker-1">
                                                    请输入患者的手机号查询：
                                                </label>
                                                <div class="row">
                                                    <div class="col-xs-3 col-sm-5">
                                                       <div class="input-group">
                                                                <span class="input-group-addon">
                                                                    <i class="icon-info-sign bigger-110"></i>
                                                                </span>
                                                                <input id="MobileId" class="form-control" type="text" />
                                                        </div>
                                                    </div>
                                                    <button onclick="searchByMobile()" class="btn btn-success btn-sm">搜索<i class="icon-search icon-on-right bigger-110"></i></button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                            <!-- <div>&nbsp;</div> -->
                            <!-- 医生信息查看表单 -->
                            <div class="table-header bgadmin" style="clear:none;">
                                购买信息查看
                            </div>
                            <div class="table-responsive">
                                <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th class="center">
                                                <label>
                                                   ID号
                                                </label>
                                            </th>
                                            <th>姓名</th>
                                            <th>手机号</th>
                                            <th>购买日期</th>
                                            <th>收货地址</th>
                                            <th class="hidden-480">产品</th>
                                            <th>单价</th>
                                            <th>数量</th>
                                            <th>总价</th>
                                            <th>医生姓名</th>
                                            <th>医生账号</th>
                                            <th>医生号码</th>
                                            <th>编辑</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach ($buInfo as $key=>$buy): ?>
                                            <tr>
                                            <td class="center">
                                                <label>
                                                    <?php echo $key+1 ?>
                                                </label>
                                            </td>
                                            <td>
                                                <?php echo $buy['name'] ?>
                                            </td>
                                            <td>
                                                <?php echo $buy['mobil'] ?>
                                            </td>
                                            <td><?php echo $buy['timeb'] ?></td>
                                            <td><?php echo $buy['address'] ?></td>
                                            <td class="hidden-480"><?php echo $buy['product'] ?></td>
                                            <td><?php echo $buy['oprice'] ?></td>
                                             <td><?php echo $buy['number'] ?></td>
                                              <td><?php echo $buy['aprice'] ?></td>
                                               <td><?php 
                                                        if(!is_null($buy['realName'])){
                                                            echo $buy['realName'];
                                                        }else{
                                                            echo $buy['realNameJ'];
                                                        }
                                                    ?>
                                               </td>
                                               <td>
                                                    <?php 
                                                        if(!is_null($buy['loginName'])){
                                                            echo $buy['loginName'];
                                                        }else{
                                                            echo "未绑定";
                                                        }
                                                    ?>
                                               </td>
                                                <td>
                                                    <?php 
                                                         if(!is_null($buy['mobile'])){
                                                            echo $buy['mobile'];
                                                        }else{
                                                            echo $buy['mobileJ'];
                                                        }

                                                    ?>
                                                </td>
                                            <td>
                                                <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                                    <a class="green" href="<?php echo site_url('admin/BuyMan/editorOneDoc/').'/'.$buy['id'] ?>" onclick="">
                                                        <i class="icon-pencil bigger-130"></i>
                                                    </a>
                                                    <a class="red" href="#" onclick="deleteForm('<?php echo $buy['id'] ?>')">
                                                        <i class="icon-trash bigger-130"></i>
                                                    </a>
                                                </div>
                                                <div class="visible-xs visible-sm hidden-md hidden-lg">
                                                    <div class="inline position-relative">
                                                        <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
                                                            <i class="icon-caret-down icon-only bigger-120"></i>
                                                        </button>
                                                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
                                                            <li>
                                                                <a href="<?php echo site_url('admin/GroupMan/editorOneDoc/').'/'.$buy['id'] ?>" class="tooltip-info" data-rel="tooltip" title="View">
                                                                    <span class="blue">
                                                                    <i class="icon-zoom-in bigger-120"></i>
                                                                </span>
                                                                </a>
                                                            </li>
                                                            <li>
                                                                <a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
                                                                    <span class="green">
                                                                    <i class="icon-edit bigger-120"></i>
                                                                </span>
                                                                </a>
                                                            </li>
                                                            <li>
                                                                <a href="javascript:void(0)" class="tooltip-error" data-rel="tooltip" onclick="deleteForm('<?php echo $buy['id'] ?>')" title="Delete">
                                                                    <span class="red">
                                                                    <i class="icon-trash bigger-120"></i>
                                                                </span>
                                                                </a>
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <?php endforeach?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
        <!-- /.main-content -->
        <div class="ace-settings-container" id="ace-settings-container">
            <!-- <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
                <i class="icon-cog bigger-150"></i>
            </div> -->
            <div class="ace-settings-box" id="ace-settings-box">
                <div>
                    <div class="pull-left">
                        <select id="skin-colorpicker" class="hide">
                            <option data-skin="default" value="#438EB9">#438EB9</option>
                            <option data-skin="skin-1" value="#222A2D">#222A2D</option>
                            <option data-skin="skin-2" value="#C6487E">#C6487E</option>
                            <option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
                        </select>
                    </div>
                    <span>&nbsp; 选择皮肤</span>
                </div>
                <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
                    <label class="lbl" for="ace-settings-navbar"> 固定导航条</label>
                </div>
                <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
                    <label class="lbl" for="ace-settings-sidebar"> 固定滑动条</label>
                </div>
                <!--   <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" />
                    <label class="lbl" for="ace-settings-breadcrumbs">固定面包屑</label>
                </div> -->
                <!-- <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" />
                    <label class="lbl" for="ace-settings-rtl">切换到左边</label>
                </div> -->
                <div>
                    <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
                    <label class="lbl" for="ace-settings-add-container">
                        切换窄屏
                        <b></b>
                    </label>
                </div>
            </div>
        </div>
        <!-- /#ace-settings-container -->
    </div>
    <!-- /.main-container-inner -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
    <!-- </div> -->
    <!-- /.main-container -->
    <!-- basic scripts -->
    <!--[if !IE]> -->
    <?php include 'js2.html' ?>
    <!-- inline scripts related to this page -->
    <script type="text/javascript">
    jQuery(function($) {
        $('#id-disable-check').on('click', function() {
            var inp = $('#form-input-readonly').get(0);
            if (inp.hasAttribute('disabled')) {
                inp.setAttribute('readonly', 'true');
                inp.removeAttribute('disabled');
                inp.value = "This text field is readonly!";
            } else {
                inp.setAttribute('disabled', 'disabled');
                inp.removeAttribute('readonly');
                inp.value = "This text field is disabled!";
            }
        });


        $(".chosen-select").chosen();
        $('#chosen-multiple-style').on('click', function(e) {
            var target = $(e.target).find('input[type=radio]');
            var which = parseInt(target.val());
            if (which == 2) $('#form-field-select-4').addClass('tag-input-style');
            else $('#form-field-select-4').removeClass('tag-input-style');
        });


        $('[data-rel=tooltip]').tooltip({
            container: 'body'
        });
        $('[data-rel=popover]').popover({
            container: 'body'
        });

        $('textarea[class*=autosize]').autosize({
            append: "\n"
        });
        $('textarea.limited').inputlimiter({
            remText: '%n character%s remaining...',
            limitText: 'max allowed : %n.'
        });

        $.mask.definitions['~'] = '[+-]';
        $('.input-mask-date').mask('99/99/9999');
        $('.input-mask-phone').mask('(999) 999-9999');
        $('.input-mask-eyescript').mask('~9.99 ~9.99 999');
        $(".input-mask-product").mask("a*-999-a999", {
            placeholder: " ",
            completed: function() {
                alert("You typed the following: " + this.val());
            }
        });



        $("#input-size-slider").css('width', '200px').slider({
            value: 1,
            range: "min",
            min: 1,
            max: 8,
            step: 1,
            slide: function(event, ui) {
                var sizing = ['', 'input-sm', 'input-lg', 'input-mini', 'input-small', 'input-medium', 'input-large', 'input-xlarge', 'input-xxlarge'];
                var val = parseInt(ui.value);
                $('#form-field-4').attr('class', sizing[val]).val('.' + sizing[val]);
            }
        });

        $("#input-span-slider").slider({
            value: 1,
            range: "min",
            min: 1,
            max: 12,
            step: 1,
            slide: function(event, ui) {
                var val = parseInt(ui.value);
                $('#form-field-5').attr('class', 'col-xs-' + val).val('.col-xs-' + val);
            }
        });


        $("#slider-range").css('height', '200px').slider({
            orientation: "vertical",
            range: true,
            min: 0,
            max: 100,
            values: [17, 67],
            slide: function(event, ui) {
                var val = ui.values[$(ui.handle).index() - 1] + "";

                if (!ui.handle.firstChild) {
                    $(ui.handle).append("<div class='tooltip right in' style='display:none;left:16px;top:-6px;'><div class='tooltip-arrow'></div><div class='tooltip-inner'></div></div>");
                }
                $(ui.handle.firstChild).show().children().eq(1).text(val);
            }
        }).find('a').on('blur', function() {
            $(this.firstChild).hide();
        });

        $("#slider-range-max").slider({
            range: "max",
            min: 1,
            max: 10,
            value: 2
        });

        $("#eq > span").css({
            width: '90%',
            'float': 'left',
            margin: '15px'
        }).each(function() {
            // read initial values from markup and remove that
            var value = parseInt($(this).text(), 10);
            $(this).empty().slider({
                value: value,
                range: "min",
                animate: true

            });
        });


        $('#id-input-file-1 , #id-input-file-2').ace_file_input({
            no_file: 'No File ...',
            btn_choose: 'Choose',
            btn_change: 'Change',
            droppable: false,
            onchange: null,
            thumbnail: false //| true | large
                //whitelist:'gif|png|jpg|jpeg'
                //blacklist:'exe|php'
                //onchange:''
                //
        });

        $('#id-input-file-3').ace_file_input({
            style: 'well',
            btn_choose: 'Drop files here or click to choose',
            btn_change: null,
            no_icon: 'icon-cloud-upload',
            droppable: true,
            thumbnail: 'small' //large | fit
                //,icon_remove:null//set null, to hide remove/reset button
                /**,before_change:function(files, dropped) {
                	//Check an example below
                	//or examples/file-upload.html
                	return true;
                }*/
                /**,before_remove : function() {
                	return true;
                }*/
                ,
            preview_error: function(filename, error_code) {
                //name of the file that failed
                //error_code values
                //1 = 'FILE_LOAD_FAILED',
                //2 = 'IMAGE_LOAD_FAILED',
                //3 = 'THUMBNAIL_FAILED'
                //alert(error_code);
            }

        }).on('change', function() {
            //console.log($(this).data('ace_input_files'));
            //console.log($(this).data('ace_input_method'));
        });


        //dynamically change allowed formats by changing before_change callback function
        $('#id-file-format').removeAttr('checked').on('change', function() {
            var before_change
            var btn_choose
            var no_icon
            if (this.checked) {
                btn_choose = "Drop images here or click to choose";
                no_icon = "icon-picture";
                before_change = function(files, dropped) {
                    var allowed_files = [];
                    for (var i = 0; i < files.length; i++) {
                        var file = files[i];
                        if (typeof file === "string") {
                            //IE8 and browsers that don't support File Object
                            if (!(/\.(jpe?g|png|gif|bmp)$/i).test(file)) return false;
                        } else {
                            var type = $.trim(file.type);
                            if ((type.length > 0 && !(/^image\/(jpe?g|png|gif|bmp)$/i).test(type)) || (type.length == 0 && !(/\.(jpe?g|png|gif|bmp)$/i).test(file.name)) //for android's default browser which gives an empty string for file.type
                            ) continue; //not an image so don't keep this file
                        }

                        allowed_files.push(file);
                    }
                    if (allowed_files.length == 0) return false;

                    return allowed_files;
                }
            } else {
                btn_choose = "Drop files here or click to choose";
                no_icon = "icon-cloud-upload";
                before_change = function(files, dropped) {
                    return files;
                }
            }
            var file_input = $('#id-input-file-3');
            file_input.ace_file_input('update_settings', {
                'before_change': before_change,
                'btn_choose': btn_choose,
                'no_icon': no_icon
            })
            file_input.ace_file_input('reset_input');
        });




        $('#spinner1').ace_spinner({
                value: 0,
                min: 0,
                max: 200,
                step: 10,
                btn_up_class: 'btn-info',
                btn_down_class: 'btn-info'
            })
            .on('change', function() {
                //alert(this.value)
            });
        $('#spinner2').ace_spinner({
            value: 0,
            min: 0,
            max: 10000,
            step: 100,
            touch_spinner: true,
            icon_up: 'icon-caret-up',
            icon_down: 'icon-caret-down'
        });
        $('#spinner3').ace_spinner({
            value: 0,
            min: -100,
            max: 100,
            step: 10,
            on_sides: true,
            icon_up: 'icon-plus smaller-75',
            icon_down: 'icon-minus smaller-75',
            btn_up_class: 'btn-success',
            btn_down_class: 'btn-danger'
        });



        $('.date-picker').datepicker({
            autoclose: true
        }).next().on(ace.click_event, function() {
            $(this).prev().focus();
        });
        $('input[name=date-range-picker]').daterangepicker().prev().on(ace.click_event, function() {
            $(this).next().focus();
        });

        $('#timepicker1').timepicker({
            minuteStep: 1,
            showSeconds: true,
            showMeridian: false
        }).next().on(ace.click_event, function() {
            $(this).prev().focus();
        });

        $('#colorpicker1').colorpicker();
        $('#simple-colorpicker-1').ace_colorpicker();


        $(".knob").knob();


        //we could just set the data-provide="tag" of the element inside HTML, but IE8 fails!
        var tag_input = $('#form-field-tags');
        if (!(/msie\s*(8|7|6)/.test(navigator.userAgent.toLowerCase()))) {
            tag_input.tag({
                placeholder: tag_input.attr('placeholder'),
                //enable typeahead by specifying the source array
                source: ace.variable_US_STATES, //defined in ace.js >> ace.enable_search_ahead
            });
        } else {
            //display a textarea for old IE, because it doesn't support this plugin or another one I tried!
            tag_input.after('<textarea id="' + tag_input.attr('id') + '" name="' + tag_input.attr('name') + '" rows="3">' + tag_input.val() + '</textarea>').remove();
            //$('#form-field-tags').autosize({append: "\n"});
        }




        /////////
        $('#modal-form input[type=file]').ace_file_input({
            style: 'well',
            btn_choose: 'Drop files here or click to choose',
            btn_change: null,
            no_icon: 'icon-cloud-upload',
            droppable: true,
            thumbnail: 'large'
        })

        //chosen plugin inside a modal will have a zero width because the select element is originally hidden
        //and its width cannot be determined.
        //so we set the width after modal is show
        $('#modal-form').on('shown.bs.modal', function() {
                $(this).find('.chosen-container').each(function() {
                    $(this).find('a:first-child').css('width', '210px');
                    $(this).find('.chosen-drop').css('width', '210px');
                    $(this).find('.chosen-search input').css('width', '200px');
                });
            })
            /**
            //or you can activate the chosen plugin after modal is shown
            //this way select element becomes visible with dimensions and chosen works as expected
            $('#modal-form').on('shown', function () {
            	$(this).find('.modal-chosen').chosen();
            })
            */


        // sammieHo-add



    });
    </script>
    <script type="text/javascript">
        jQuery(function($) {
        var oTable1 = $('#sample-table-2').dataTable({
             // "aoColumns": [{
            //         // "bSortable": false
            //         { "mDataProp": "id" },
            //         { "mDataProp": "title" }
            //     },
            //     null, null, null, null, null, {
            //         "bSortable": false
            //     }
            // ]
            // "bProcessing": true,
            "bSort": true,
            "bAutoWidth": false,    
        });


        $('table th input:checkbox').on('click', function() {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function() {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({
            placement: tooltip_placement
        });

        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })

    function subAddDoctor(){

            var addNameid=document.getElementById("addNameid").value;
            var addMobileid=document.getElementById("addMobileid").value;
            var addAddressid=document.getElementById("addAddressid").value;
            var addProuctid=document.getElementById("addProuctid").value;
            var addOpriceid=document.getElementById("addOpriceid").value;
            var addnumberid=document.getElementById("addnumberid").value;
            var addApriceid=document.getElementById("addApriceid").value;
            var addBuyTimeid=document.getElementById("addBuyTimeid").value;
            var addBeizhu=document.getElementById("addBeizhu").value;

            if(addNameid.length<=0){
                alert("姓名不能为空");
                return;
            }
            if(addMobileid.length<=0){
                alert("电话不能为空");
                return;
            }
            if(addProuctid.length<=0){
                alert("产品不能为空");
                return;
            }
            if(addOpriceid.length<=0){
                alert("单价不能为空");
                return;
            }
            if(addnumberid.length<=0){
                alert("数量不能为空");
                return;
            }
             if(addApriceid.length<=0){
                alert("总价不能为空");
                return;
            }
            if(addBuyTimeid.length<=0){
                alert("购买时间不能为空");
                return;
            }
             $.ajax({
                url : '<?php echo site_url('admin/BuyMan/addBuyRecordOne'); ?>',
                type : 'post',
                data : {
                    addNameid:addNameid,
                    addMobileid:addMobileid,
                    addAddressid:addAddressid,
                    addProuctid:addProuctid,
                    addOpriceid:addOpriceid,
                    addnumberid:addnumberid,
                    addApriceid:addApriceid,
                    addBuyTimeid:addBuyTimeid,
                    addBeizhu:addBeizhu
                },
                success : function (data, response, status) {
                    if(data==0){
                        alert("用户名已经存在");
                    }else if(data==1){
                        alert("添加成功");
                        window.location.href="<?php echo site_url('admin/BuyMan/index'); ?>";
                    }else{
                        alert(data);
                    }
                }
            });
    
        }

        function shuaxin(){
            location.href = '<?php echo site_url('admin/BuyMan/index'); ?>';
        }

        function searchDoctor(){
            var ss=encodeURIComponent(document.getElementById("docotrNameid").value);
            var url="<?php echo site_url('admin/BuyMan/Pasearch'); ?>";
            window.location.href=url+'?info='+ss; 
        }
        function searchByMobile(){
            var ss=encodeURIComponent(document.getElementById("MobileId").value);
            var url="<?php echo site_url('admin/BuyMan/Mosearch'); ?>";
            window.location.href=url+'?info='+ss; 
        }

        function searchDName(){
            var ss=encodeURIComponent(document.getElementById("DoctorId").value);
            var url="<?php echo site_url('admin/BuyMan/Dnsearch'); ?>";
            window.location.href=url+'?info='+ss; 
        }

        function searchTime(){
            var ss=document.getElementById("timeid").value;
            var url="<?php echo site_url('admin/BuyMan/Tisearch'); ?>";
            window.location.href=url+'?info='+ss;
        }

        function testphp(){
            var url="<?php echo site_url('admin/BuyMan/testexcel'); ?>";
            window.location.href=url;
        }

        function deleteForm(id)
        {
               if (confirm("你确定删除这条数据吗？")) {  
                   if(id.length==0)
                   {
                     alert("非法提交");
                   }else{

                     $.ajax({
                        url : '<?php echo site_url('admin/BuyMan/deleteOne'); ?>',
                        type : 'post',
                        data : {
                            DoctorId:id
                        },
                        
                        success : function (data, response, status) {
                            if(data==0){
                                alert("删除失败");
                            }else if(data==1){
                                location.href='<?php echo site_url('admin/BuyMan/index'); ?>';
                            }else{
                                alert(data);
                            }
                        }
                     });

                   }
                }  
        }


    </script>

</body>

</html>
